<?//引入所有子系统信息
//include_once("../../../common/script/extender_import.php");
?>


<?
//获取网站信息
$site=select_one_line_all_items($table_Prefix."site","1 = 1");

//获取板块信息
$plate=select_one_line_all_items($table_Prefix."plate","mid = 'banner' ");


//获取板块分类
$term=select_lines_all_items($table_Prefix."banner_term","mid asc","publish = 1","");
$term_name_list=transform_2darray_in_1darray_with_new_key($term,"nid","name");



?>






<?
//接收传递过来的分类id
$trans_nid   = addslashes($_REQUEST ['nid']);

if(!$trans_nid)
{$trans_nid=0;}

?>



<?
//设置需要搜索的表格的前缀后缀 和 默认搜索排序
$table        = $table_Prefix."detail";
$sort_by      = "nid";
$sort_order   = "desc";
//设置需要搜索的表格的前缀后缀 和 默认搜索排序
?>







<?php

$count_num_sql="SELECT COUNT(nid) FROM $table where  belong = 'banner' and (status is null or status != '已删除') ";
$query = mysql_query($count_num_sql);
$sum = mysql_result($query, 0);

$nowpageid=1;
$detailnum=5;//每页显示多少个产品


if ($_REQUEST ['nowpageid'])
{
    $nowpageid = $_REQUEST ['nowpageid'];
}
else
{$nowpageid =1;}



//计算一下结果，从那条数据开始显示
$detailstar=($nowpageid-1)*$detailnum;





if($sum)
{

    if ($sum< $detailnum)
    {$page_count=1;
        $detailnum=$sum;}//如果总数据量小于$Pagenum,（pagenum作为每页显示数据的条数，）那么只有一页,而pagenum也更改为sum 


    else if($sum % $detailnum)
    {$page_count = (int) ($sum / $detailnum) + 1;}
    //取总数据量除以每页数的余数 
    //如果有余数，则页数等于总数据量除以每页数的结果取整再加一


    else
    {$page_count = $sum / $detailnum ;}//如果没有余数，则页数等于总数据量除以每页数的结果 

}


else
{$page_count = 0;$detailnum=0;}



$lastpage=$page_count;
$prepage=$nowpageid-1;
$nextpage=$nowpageid+1;


if ($nowpageid==1)
{$prepage=1;}


if ($nowpageid==$page_count)
{

    if($sum<=$detailnum)//总数数据少于每页显示数目，就把循环改成总数数目
    {$detailnum=$sum;
        $nextpage=$nowpageid;}

    else
    {
        $nextpage=$nowpageid;
        $detailnum=fmod($sum,$detailnum);
        if($detailnum==0)//这个if是因为当数据正好30条，能除尽的话，最后一页就会因为fmod能整除的缘故，最后一页不显示数据
        {$detailnum=5;}
    }//如果现在页数等于总页数（总页数上面求出，最后一页不够循环数的时候），那么最后一页的detailnum就会等于余下数据(不足一页)的数目.

}

?>



<?

if ($_REQUEST ['sortby'])
{
    $sort_by = $_REQUEST ['sortby'];
}


if ($_REQUEST ['sortorder'])
{
    $sort_order = $_REQUEST ['sortorder'];
}







$detail_sql="select * from $table where belong = 'banner'  and (status is null or status != '已删除') ORDER BY $sort_by $sort_order  limit $detailstar , $detailnum";
$result = mysql_query($detail_sql);

while($row = mysql_fetch_array($result))
{

    $detail[]=$row;
}
mysql_close($con);


?>








